/*    */ package com.iris.egrant.remote.http.service;
/*    */ 
/*    */ import java.io.Serializable;
/*    */ import org.apache.commons.lang.StringUtils;
/*    */ import org.springframework.beans.BeansException;
/*    */ import org.springframework.beans.factory.BeanFactory;
/*    */ import org.springframework.beans.factory.BeanFactoryAware;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class LocalServiceFactory
/*    */   implements Serializable, ServiceFactory, BeanFactoryAware
/*    */ {
/*    */   private static final long serialVersionUID = -4829342420862083368L;
/*    */   private BeanFactory beanFactory;
/*    */   
/*    */   public <T> T getService(Class<T> clazz) {
/* 24 */     String beanId = getServiceName(clazz, null);
/* 25 */     return (T)this.beanFactory.getBean(beanId, clazz);
/*    */   }
/*    */ 
/*    */   
/*    */   public <T> T getService(String beanId, Class<T> clazz) {
/* 30 */     beanId = getServiceName(clazz, beanId);
/* 31 */     return (T)this.beanFactory.getBean(beanId, clazz);
/*    */   }
/*    */   
/*    */   private <T> String getServiceName(Class<T> clazz, String serviceName) {
/* 35 */     String beanName = serviceName;
/* 36 */     if (StringUtils.isBlank(serviceName)) {
/*    */       
/* 38 */       beanName = clazz.getName().substring(clazz.getName().lastIndexOf(".") + 1);
/*    */       
/* 40 */       beanName = beanName.substring(0, 1).toLowerCase() + beanName.substring(1);
/*    */     } 
/* 42 */     return beanName;
/*    */   }
/*    */ 
/*    */   
/*    */   public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
/* 47 */     this.beanFactory = beanFactory;
/*    */   }
/*    */ }


/* Location:              D:\文件kjt\WEB-INF\lib\egrant-core-2.2.20240205.1659.jar!\com\iris\egrant\remote\http\service\LocalServiceFactory.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */